#include <stdio.h>

// 计算并返回n天中门票销售数量的最大值
int MaxTicketNumber(int tickets[], int n) {
    int max = tickets[0];
    for (int i = 1; i < n; i++) {
        if (tickets[i] > max) {
            max = tickets[i];
        }
    }
    return max;
}

// 计算并返回n天销售门票数量的排序(升序，门票数量按照从低到高排列)
void Sort(int tickets[], int n) {
    int i, j, temp;
    for (i = 0; i < n-1; i++) {
        for (j = 0; j < n-i-1; j++) {
            if (tickets[j] > tickets[j+1]) {
                temp = tickets[j];
                tickets[j] = tickets[j+1];
                tickets[j+1] = temp;
            }
        }
    }
}

int main() {
    int n;
    printf("Enter the day number:\n");
    scanf("%d", &n);

    int tickets[n];
    printf("Enter the ticket number between(0<=n<=10000):\n");
    for (int i = 0; i < n; i++) {
        scanf("%d", &tickets[i]);
    }

    int max_ticket = MaxTicketNumber(tickets, n);
    printf("The highest ticket number is: %d\n", max_ticket);

    Sort(tickets, n);
    printf("The sorted ticket numbers are（low to high）: ");
    for (int i = 0; i < n; i++) {
        printf("%d ", tickets[i]);
    }
    printf("\n");

    return 0;
}
